package Perlescent::Config;

use Exporter qw(import);
use strict;
use warnings;
our(@ISA,@EXPORT,@EXPORT_OK);
	
@EXPORT = qw(
	     );
@EXPORT_OK = qw(
	        );

sub new
{
    my $class = shift;
    my $self = {};
    bless $self, $class;
    my $caller = caller;
    return $self;
}

sub loadConfig
{
	my %config;

	while (my $line = <DATA>)
	{
		my($key,$value) = split(/\=/, $line);
		chomp($key,$value);
		$config{$key} = "$value";
	}

	return %config;
}

sub writeConfig
{
	   shift;
	   my $config = shift;
	   my %oldcfg = &loadConfig;
	
	   my @items;
	   while (my($k,$v) = each %{$config})
	   {
	        push(@items, "$k=$config->{$k}");
	   }
	   while (my($ok,$ov) = each %oldcfg)
	   {
	        unless($config->{$ok})
	        {
	           push(@items, "$ok=$oldcfg{$ok}");
	        }
	   }
	        foreach my $item (sort @items)
	        {
	           print DATA "$item\n";
	           &writeLog("writeConfig","INFO","$item");
	        }
	  return 1;
}

1;

__DATA__
THEME=default
FULL_PATH=/var/pwneth/htdocs/perlescent
P_TITLE=Perlescent
P_DESC=A Shining Example
P_URI=http://pwneth.com/perlescent
